#include <iostream>
#include <assert.h>

using namespace std;

int *copyArray(int a[], int n) {
    int *arr = new int[n];
    copy(a, a + n, arr);
    return arr;
}
template <typename T>
void insertionSort(T arr[],int n){
    for (int i = 1; i < n; ++i) {
        T e=arr[i];
        int j;
        for ( j = i; j > 0 && arr[j - 1]>e; j--)
            arr[j]=arr[j - 1];
        arr[j]=e;
    }
    return;
}
int findindex(int arr[],int n,int num){
    if(arr[0]>num || arr[n-1]<num){
        return -1;
    }
    else if (arr[n-1]==num) {
        return n-1;
    }
    else{
        for (int i = 0; i < n-1; ++i)
            if (arr[i] <= num && arr[i + 1] > num)
                return i;
    }

}
int main(){
    int N,M;
    while(cin>>N>>M){

        assert(N<=100000&&M<=100000);
        cout<<endl;
        int* arr1= new int[N];
        int* arr2= new int[N];
        for(int i=0;i<N;i++){
            cin>>arr1[i]>>arr2[i];
            assert(arr1[i]<=1000000000&&arr2[i]<=1000000000);
        }
        int* arr3=new int[M];
        for(int j=0;j<M;j++){
            cin>>arr3[j];
            assert(arr3[j]<=1000000000);
        }
        int* arr4=copyArray(arr1,N);
        insertionSort(arr4,N);


        for (int k = 0; k < M; ++k) {

            cout<<arr2[findindex(arr4,N,arr3[k])]<<endl;
        }


        delete[] arr1;
        delete[] arr2;
        delete[] arr3;
        delete[] arr4;
    }

    return 0;

}